﻿using BlueportCoffee.CoffeeModel;
using BlueportCoffee.http;
using BlueportCoffee.IceModel;
using BlueportCoffee.LabelingModle;
using BlueportCoffee.MilkTeaModel;
using BlueportCoffee.model;
using BlueportCoffee.RobotModel;
using BlueportCoffee.SocketModel;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading;
using System.Windows;
using System.Windows.Controls;

namespace BlueportCoffee
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }
        public static string IPorPortUrl = AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"IPorPortMessage.txt";
        /// <summary>
        /// M12警告
        /// </summary>
        public static string WarnPath = AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"Warn";
        /// <summary>
        /// M12故障
        /// </summary>
        public static string BreakPath = AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"BreakDowm";
        public static List<CCUpDateOrder> updateOrders = new List<CCUpDateOrder>();
        public static bool IsOutCup = false;
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                #region
                //  MilkTeaSocket.Instance.SendMsg(JsonConvert.SerializeObject(locks2) + "###");
                //  MilkTeaSocket.Instance.SendMsg(JsonConvert.SerializeObject(makeList) + "###");
                //var data = HttpMsg.Instance.deviceOrderQueueListMsg();
                //var msglist = JsonConvert.DeserializeObject<HTTPMsg>(data);
                //var msglists = JsonConvert.DeserializeObject<deviceOrderQueueList>(msglist.data.ToString());
                //updateOrderStatus editDevice = new updateOrderStatus();
                //editDevice.productId = IPorPortInfo.Instance.ProductId;
                //editDevice.deviceName = IPorPortInfo.Instance.DeviceName;
                //editDevice.orderId = msglists.orderId;
                //editDevice.childOrderId = msglists.goodsList[0].childOrderId;
                //editDevice.status = "1";
                //string lists = JsonConvert.SerializeObject(editDevice);
                //var dd1 = HttpMsg.Instance.editDeviceOrderStatusMsg(lists);

                //updateOrderStatus editDevice2 = new updateOrderStatus();
                //editDevice2.productId = IPorPortInfo.Instance.ProductId;
                //editDevice2.deviceName = IPorPortInfo.Instance.DeviceName;
                //editDevice2.orderId = msglists.orderId;
                //editDevice2.childOrderId = msglists.goodsList[0].childOrderId;
                //editDevice2.status = "2";
                //editDevice2.pickUpLocation = "A";
                //string lists2 = JsonConvert.SerializeObject(editDevice2);
                //var dd2 = HttpMsg.Instance.editDeviceOrderStatusMsg(lists2);

                //updateOrderStatus editDevice3 = new updateOrderStatus();
                //editDevice3.productId = IPorPortInfo.Instance.ProductId;
                //editDevice3.deviceName = IPorPortInfo.Instance.DeviceName;
                //editDevice3.orderId = msglists.orderId;
                //editDevice3.childOrderId = msglists.goodsList[0].childOrderId;
                //editDevice3.status = "3";
                //editDevice3.pickUpLocation = "A";
                //string lists3 = JsonConvert.SerializeObject(editDevice3);
                //var dd3 = HttpMsg.Instance.editDeviceOrderStatusMsg(lists3);
                //Alter alter = new Alter();
                //alter.equipNo = "10084";
                //alter.equipAlterInfo = "出餐口已有空闲位置";
                //alter.equipAlterType = "6";
                //string lists1 = JsonConvert.SerializeObject(alter);
                //HttpMsg.Instance.saveDeviceMatterMsg(lists1);
                #endregion
                if (!File.Exists(IPorPortUrl))
                {
                    using (FileStream stream = File.Create(IPorPortUrl))
                    {
                        stream.Close();
                        stream.Dispose();
                        IPorPortInfo porPortInfo1 = IPorPortInfo.Instance;
                        File.WriteAllText(IPorPortUrl, JsonConvert.SerializeObject(porPortInfo1));
                    }
                }
                else
                {
                    var dd = File.ReadAllText(IPorPortUrl);
                    var porPortInfo = JsonConvert.DeserializeObject<IPorPortInfo>(File.ReadAllText(IPorPortUrl));
                    IPorPortInfo.Instance.CoffeeIP = porPortInfo.CoffeeIP;
                    IPorPortInfo.Instance.CoffeePort = porPortInfo.CoffeePort;
                    IPorPortInfo.Instance.ProductId = porPortInfo.ProductId;
                    IPorPortInfo.Instance.DeviceName = porPortInfo.DeviceName;
                    IPorPortInfo.Instance.token = porPortInfo.token;
                    IPorPortInfo.Instance.RobotIPLeft = porPortInfo.RobotIPLeft;
                    IPorPortInfo.Instance.MilkTeaIP = porPortInfo.MilkTeaIP;
                    IPorPortInfo.Instance.MilkTeaPort = porPortInfo.MilkTeaPort;
                    IPorPortInfo.Instance.PortName = porPortInfo.PortName;
                    IPorPortInfo.Instance.PortNameShow = porPortInfo.PortNameShow;
                    IPorPortInfo.Instance.EWMPortName = porPortInfo.EWMPortName;
                    IPorPortInfo.Instance.ZBPortName = porPortInfo.ZBPortName;
                    IPorPortInfo.Instance.WaterPortName = porPortInfo.WaterPortName;
                    IPorPortInfo.Instance.CoffeePortName = porPortInfo.CoffeePortName;
                    IPorPortInfo.Instance.SugarInit1 = porPortInfo.SugarInit1;
                    IPorPortInfo.Instance.SugarInit2 = porPortInfo.SugarInit2;
                    IPorPortInfo.Instance.SugarInit3 = porPortInfo.SugarInit3;
                    IPorPortInfo.Instance.RobotPortLeft = porPortInfo.RobotPortLeft;
                    IPorPortInfo.Instance.RobotPortRight = porPortInfo.RobotPortRight;
                    IPorPortInfo.Instance.IceCoffee = porPortInfo.IceCoffee;
                    IPorPortInfo.Instance.IceMilk = porPortInfo.IceMilk;
                }
                if (!Directory.Exists(WarnPath))
                {
                    Directory.CreateDirectory(WarnPath);
                }
                if (!Directory.Exists(WarnPath + @"\" + DateTime.Now.ToString("yyyy")))
                {
                    Directory.CreateDirectory(WarnPath + @"\" + DateTime.Now.ToString("yyyy"));
                }
                if (!Directory.Exists(WarnPath + @"\" + DateTime.Now.ToString("yyyy") + @"\" + DateTime.Now.ToString("MM")))
                {
                    Directory.CreateDirectory(WarnPath + @"\" + DateTime.Now.ToString("yyyy") + @"\" + DateTime.Now.ToString("MM"));
                }
                if (!Directory.Exists(WarnPath + @"\" + DateTime.Now.ToString("yyyy") + @"\" + DateTime.Now.ToString("MM") + @"\" + DateTime.Now.ToString("dd")))
                {
                    Directory.CreateDirectory(WarnPath + @"\" + DateTime.Now.ToString("yyyy") + @"\" + DateTime.Now.ToString("MM") + @"\" + DateTime.Now.ToString("dd"));
                }
                WarnPath = WarnPath + @"\" + DateTime.Now.ToString("yyyy") + @"\" + DateTime.Now.ToString("MM") + @"\" + DateTime.Now.ToString("dd");
                if (!Directory.Exists(BreakPath))
                {
                    Directory.CreateDirectory(BreakPath);
                }
                if (!Directory.Exists(BreakPath + @"\" + DateTime.Now.ToString("yyyy")))
                {
                    Directory.CreateDirectory(BreakPath + @"\" + DateTime.Now.ToString("yyyy"));
                }
                if (!Directory.Exists(BreakPath + @"\" + DateTime.Now.ToString("yyyy") + @"\" + DateTime.Now.ToString("MM")))
                {
                    Directory.CreateDirectory(BreakPath + @"\" + DateTime.Now.ToString("yyyy") + @"\" + DateTime.Now.ToString("MM"));
                }
                if (!Directory.Exists(BreakPath + @"\" + DateTime.Now.ToString("yyyy") + @"\" + DateTime.Now.ToString("MM") + @"\" + DateTime.Now.ToString("dd")))
                {
                    Directory.CreateDirectory(BreakPath + @"\" + DateTime.Now.ToString("yyyy") + @"\" + DateTime.Now.ToString("MM") + @"\" + DateTime.Now.ToString("dd"));
                }
                BreakPath = BreakPath + @"\" + DateTime.Now.ToString("yyyy") + @"\" + DateTime.Now.ToString("MM") + @"\" + DateTime.Now.ToString("dd");
                Thread thr12 = new Thread(SocketClients.Instance.socketclient);
                thr12.IsBackground = true;
                thr12.Start();
                Thread thread7 = new Thread(CcSucess);
                thread7.IsBackground = true;
                thread7.Start();
                Thread thread8 = new Thread(HeartShow);
                thread8.IsBackground = true;
                thread8.Start();
                LabelMsg.Instance.EnumUSB();

            }
            catch (Exception)
            {
                return;
            }
        }
        public void HeartShow()
        {
            while (true)
            {
                try
                {
                    HttpMsg.Instance.HeartCheckListMsg();
                    Thread.Sleep(5000);
                }
                catch (Exception)
                {
                    Thread.Sleep(5000);
                }
            }
        }
        public void CcSucess()
        {
            try
            {
                while (true)
                {
                    try
                    {
                        foreach (var item in updateOrders)
                        {
                            if ((item.CcInit == 1 && !WuLiaoCoffeeSel.Instance.OutMealCup_Sel_Bol1) || (item.CcInit == 2 && !WuLiaoCoffeeSel.Instance.OutMealCup_Sel_Bol2) || (item.CcInit == 3 && !WuLiaoCoffeeSel.Instance.OutMealCup_Sel_Bol3) || (item.CcInit == 4 && !WuLiaoCoffeeSel.Instance.OutMealCup_Sel_Bol4))
                            {
                                updateOrderStatus editDevice = new updateOrderStatus();
                                editDevice.productId = IPorPortInfo.Instance.ProductId;
                                editDevice.deviceName = IPorPortInfo.Instance.DeviceName;
                                editDevice.orderId = item.status.orderId;
                                editDevice.childOrderId = item.status.childOrderId;
                                editDevice.status = "3";
                                string lists = JsonConvert.SerializeObject(editDevice);
                                var dd = HttpMsg.Instance.editDeviceOrderStatusMsg(lists);
                                updateOrders.Remove(item);
                                break;
                            }
                        }
                        Thread.Sleep(50);
                    }
                    catch (Exception)
                    {
                        Thread.Sleep(10);
                    }
                }
            }
            catch (Exception)
            {

            }
        }
        public static void MessageShow()
        {
            try
            {
                while (true)
                {
                    try
                    {
                        var data = HttpMsg.Instance.deviceOrderQueueListMsg();
                        if (data != "")
                        {
                            var msglist = JsonConvert.DeserializeObject<HTTPMsg>(data);
                            if (msglist.data != null)
                            {
                                if (msglist.data.ToString().Length > 10)
                                {
                                    var msglists = JsonConvert.DeserializeObject<deviceOrderQueueList>(msglist.data.ToString());
                                    if (msglists != null)
                                    {
                                        //bool robotL = RobotModelLeft.Instance.LRobotJQRYX_Sel();
                                        //if (robotL)
                                        //{
                                        foreach (var item in msglists.goodsList)
                                        {
                                            int RobotInit = 0;
                                            while (!RobotModelLeft.Instance.LRobotJQRYX_Sel())
                                            {
                                                RobotInit++;
                                                Thread.Sleep(100);
                                            }
                                            if (RobotInit >= 10)
                                            {
                                                Thread.Sleep(1000);
                                            }
                                            Console.WriteLine("订单开始");
                                            CoffeeMaking(item, msglists.orderId, msglists.cupSealModel);
                                            Console.WriteLine("订单完成");
                                        }
                                        // }
                                    }
                                }
                            }
                        }
                        //var msglists = JsonConvert.DeserializeObject<deviceOrderQueueList>(msglist.data.ToString());
                    }
                    catch (Exception)
                    {
                        Thread.Sleep(500);
                    }
                    Thread.Sleep(500);
                }
            }
            catch (Exception)
            {
            }
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="order">订单信息</param>
        /// <param name="orderId">总订单id</param>
        /// <param name="cupSealModel">封杯模式 1 封膜，2压盖</param>
        public static void CoffeeMaking(DeviceOrderQueue order, string orderId, int cupSealModel)
        {
            try
            {
                while ((WuLiaoCoffeeSel.Instance.OutMealCup_Sel_Bol1 && WuLiaoCoffeeSel.Instance.OutMealCup_Sel_Bol2 && WuLiaoCoffeeSel.Instance.OutMealCup_Sel_Bol3 && WuLiaoCoffeeSel.Instance.OutMealCup_Sel_Bol4) || WuLiaoCoffeeSel.Instance.LabelingMachine_Sel_Bol)
                {
                    //if (!IsOutCup)
                    //{
                    //    Alter alter = new Alter();
                    //    alter.equipNo = "10084";
                    //    alter.equipAlterInfo = "出餐口已满";
                    //    alter.equipAlterType = "5";
                    //    string lists1 = JsonConvert.SerializeObject(alter);
                    //    HttpMsg.Instance.saveDeviceMatterMsg(lists1);
                    //    IsOutCup = true;
                    //}
                    Thread.Sleep(10);
                }
                //if (IsOutCup)
                //{
                //    Alter alter = new Alter();
                //    alter.equipNo = "10084";
                //    alter.equipAlterInfo = "出餐口已有空闲位置";
                //    alter.equipAlterType = "6";
                //    string lists1 = JsonConvert.SerializeObject(alter);
                //    HttpMsg.Instance.saveDeviceMatterMsg(lists1);
                //    IsOutCup = false;
                //}
                MilkTeaSocket.Instance.AllBol = false;
                updateOrderStatus editDevice = new updateOrderStatus();
                editDevice.productId = IPorPortInfo.Instance.ProductId;
                editDevice.deviceName = IPorPortInfo.Instance.DeviceName;
                editDevice.orderId = orderId;
                editDevice.childOrderId = order.childOrderId;
                editDevice.status = "1";
                string lists = JsonConvert.SerializeObject(editDevice);
                var dd = HttpMsg.Instance.editDeviceOrderStatusMsg(lists);
                string SignageInit = "1";//咖啡1，奶茶2 混合3
                string IceInit = "12";//正常冰10 少冰11 去冰12
                string SugarInit = "20";//0糖 20  3分糖 21 5分糖 22   7分糖 23
                string CupInit = "01";//中杯00 大杯10 中杯01  大杯02 特大03
                string code = "001";//品类
                int CcInit = 0;
                if (order.goodsId.Length >= 8)
                {
                    SignageInit = order.goodsId.Substring(4, 1);
                    code = order.goodsId.Substring(5, 3);
                }
                if (order.iceContent.Length >= 2)
                    IceInit = order.iceContent.Substring(order.iceContent.Length - 2, 2);
                if (order.sugarContent.Length >= 2)
                    SugarInit = order.sugarContent.Substring(order.sugarContent.Length - 2, 2);
                if (order.cupType.Length >= 2)
                    CupInit = order.cupType.Substring(order.cupType.Length - 2, 2);
                if (SignageInit == "1")
                    RobotModelLeft.Instance.RobotKFP_UP();
                else if (SignageInit == "2")
                    RobotModelLeft.Instance.RobotNCP_UP();
                else
                    RobotModelLeft.Instance.RobotHHP_UP();
                Thread.Sleep(100);
                if (IceInit != "12")
                    RobotModelLeft.Instance.RobotQJB_UP();
                Thread.Sleep(100);
                if (order.sealingFilm == "1")
                    RobotModelLeft.Instance.RobotQYM_UP();
                else
                    RobotModelLeft.Instance.RobotWGWM_UP();
                Thread.Sleep(100);
                RobotModelLeft.Instance.RobotKSZZ_UP();
                Thread.Sleep(100);
                IOSerialPort.Instance.SerialSend(DigitalMsg.Instance.RobotLight_start);
                Thread.Sleep(100);
                QBMsg(CupInit);

                Thread.Sleep(200);
                while (true)
                {
                    if ((WuLiaoCoffeeSel.Instance.TakeCup_Sel_Bol1 && CupInit == "01") || (WuLiaoCoffeeSel.Instance.TakeCup_Sel_Bol1 && CupInit == "10") || (WuLiaoCoffeeSel.Instance.TakeCup_Sel_Bol2 && CupInit == "02") || (WuLiaoCoffeeSel.Instance.TakeCup_Sel_Bol2 && CupInit == "00"))
                    {
                        Thread.Sleep(200);
                        RobotModelLeft.Instance.RobotJBCG_UP();
                        Thread.Sleep(100);
                        RobotModelLeft.Instance.RobotKSZZ_Down();
                        Thread.Sleep(200);
                        IOSerialPort.Instance.SerialSend(DigitalMsg.Instance.RobotLight_end);
                        Thread.Sleep(100);
                        if (IceInit != "12")
                            JIceMsg(IceInit, SignageInit, CupInit);
                        if (SignageInit == "1")
                        {
                            while (!coffeeMsg.Instance.isMaking) { Thread.Sleep(10); }
                            Thread.Sleep(100);
                            IOSerialPort.Instance.SerialSend(DigitalMsg.Instance.CoffeeLight_start);
                            Thread.Sleep(100);
                            RobotModelLeft.Instance.RobotQKFJ_UP();
                            #region 咖博士
                            coffeeMsg.Instance.AllBol = false;
                            Thread.Sleep(500);
                            MakeCoffeeNow(code, CupInit, IceInit);
                            Thread.Sleep(500);
                            coffeeMsg.Instance.AllBol = true;
                            Thread.Sleep(100);
                            //IOSerialPort.Instance.SerialSend(DigitalMsg.Instance.LRobot_KFJ_Down);
                            //RobotModelLeft.Instance.QK();
                            Thread.Sleep(1000);
                            while (coffeeMsg.Instance.isMaking && (coffeeMsg.Instance.isBreakDown && coffeeMsg.Instance.isWarn)) { Thread.Sleep(10); }
                            Thread.Sleep(1000);
                            while ((!coffeeMsg.Instance.isMaking && !coffeeMsg.Instance.IsJBol) && (coffeeMsg.Instance.isBreakDown && coffeeMsg.Instance.isWarn)) { Thread.Sleep(10); }
                            #endregion
                            Thread.Sleep(100);
                            RobotModelLeft.Instance.RobotCKFWC_UP();
                            Thread.Sleep(100);
                            RobotModelLeft.Instance.RobotQKFJ_Down();
                            Thread.Sleep(100);
                            IOSerialPort.Instance.SerialSend(DigitalMsg.Instance.CoffeeLight_end);
                            Thread.Sleep(100);
                        }
                        else
                        {
                            int DevInit = 0;
                            while (true)
                            {
                                Devies coffeemake = new Devies();
                                MilkTeaSocket.Instance.SendMsg(JsonConvert.SerializeObject(coffeemake) + "###");

                                while (!MilkTeaSocket.Instance.IsDev)
                                {
                                    DevInit++;
                                    Thread.Sleep(100);
                                    if (DevInit == 20)
                                    {
                                        Devies coffeemake1 = new Devies();
                                        MilkTeaSocket.Instance.SendMsg(JsonConvert.SerializeObject(coffeemake1) + "###");
                                    }
                                    else if (DevInit == 40)
                                    {
                                        break;
                                    }
                                }
                                DevInit = 0;
                                Thread.Sleep(1000);
                                if (MilkTeaSocket.Instance.status == 0)
                                {
                                    MilkTeaSocket.Instance.IsDev = false;
                                    break;
                                }
                                MilkTeaSocket.Instance.IsDev = false;
                            }
                            MilkTeaSocket.Instance.Islock = false;
                            LockModel lockModel = new LockModel();
                            lockModel.status = 1;
                            Lock locks = new Lock();
                            locks.data = lockModel;
                            MilkTeaSocket.Instance.SendMsg(JsonConvert.SerializeObject(locks) + "###");
                            int lockInit = 0;
                            while (!MilkTeaSocket.Instance.Islock)
                            {
                                lockInit++;
                                Thread.Sleep(100);
                                if (lockInit == 20)
                                {
                                    MilkTeaSocket.Instance.Islock = false;
                                    LockModel lockModel1 = new LockModel();
                                    lockModel1.status = 1;
                                    Lock locks1 = new Lock();
                                    locks1.data = lockModel1;
                                    MilkTeaSocket.Instance.SendMsg(JsonConvert.SerializeObject(locks1) + "###");
                                }
                                else if (lockInit == 40)
                                {
                                    break;
                                }
                            }
                            Thread.Sleep(100);
                            IOSerialPort.Instance.SerialSend(DigitalMsg.Instance.MilkTeaMachineLight_start);
                            Thread.Sleep(100);
                            RobotModelLeft.Instance.RobotQNCJ_UP();
                            Thread.Sleep(100);
                            while (true)
                            {
                                bool RobotBol = false;
                                Thread.Sleep(200);
                                RobotBol = RobotModelLeft.Instance.LRobotDNCJ_Sel();
                                Thread.Sleep(200);
                                if (RobotBol)
                                {
                                    RobotModelLeft.Instance.RobotQNCJ_Down();
                                    Thread.Sleep(100);
                                    break;
                                }
                            }
                            MilkTeaSocket.Instance.Ismake = false;
                            Make makes = new Make();
                            makes.codes = order.goodsId + CupInit + IceInit + SugarInit;
                            MakeList makeList = new MakeList();
                            makeList.data = makes;
                            MilkTeaSocket.Instance.SendMsg(JsonConvert.SerializeObject(makeList) + "###");
                            int MakeInit = 0;
                            while (!MilkTeaSocket.Instance.Ismake)
                            {
                                MakeInit++;
                                Thread.Sleep(100);
                                if (MakeInit == 20)
                                {
                                    MilkTeaSocket.Instance.Ismake = false;
                                    Make makes1 = new Make();
                                    makes1.codes = order.goodsId + CupInit + IceInit + SugarInit;
                                    MakeList makeList1 = new MakeList();
                                    makeList1.data = makes1;
                                    MilkTeaSocket.Instance.SendMsg(JsonConvert.SerializeObject(makeList1) + "###");
                                }
                                else if (MakeInit == 40)
                                {
                                    break;
                                }
                            }
                            Thread.Sleep(3000);
                            DevInit = 0;
                            while (true)
                            {
                                MilkTeaSocket.Instance.IsDev = false;
                                Devies coffeemake2 = new Devies();
                                MilkTeaSocket.Instance.SendMsg(JsonConvert.SerializeObject(coffeemake2) + "###");


                                while (!MilkTeaSocket.Instance.IsDev)
                                {
                                    DevInit++;
                                    Thread.Sleep(100);
                                    if (DevInit == 20)
                                    {
                                        Devies coffeemake1 = new Devies();
                                        MilkTeaSocket.Instance.SendMsg(JsonConvert.SerializeObject(coffeemake1) + "###");
                                    }
                                    else if (DevInit == 40)
                                    {
                                        break;
                                    }
                                }
                                DevInit = 0;
                                Thread.Sleep(1000);
                                if (MilkTeaSocket.Instance.status == 0)
                                {
                                    MilkTeaSocket.Instance.IsDev = false;
                                    break;
                                }
                                MilkTeaSocket.Instance.IsDev = false;
                            }
                            Thread.Sleep(1000);
                            MilkTeaSocket.Instance.Islock = false;
                            LockModel lockModel2 = new LockModel();
                            lockModel2.status = 0;
                            Lock locks2 = new Lock();
                            locks2.data = lockModel2;
                            MilkTeaSocket.Instance.SendMsg(JsonConvert.SerializeObject(locks2) + "###");
                            lockInit = 0;
                            while (!MilkTeaSocket.Instance.Islock)
                            {
                                lockInit++;
                                Thread.Sleep(100);
                                if (lockInit == 20)
                                {
                                    MilkTeaSocket.Instance.Islock = false;
                                    LockModel lockModel1 = new LockModel();
                                    lockModel1.status = 0;
                                    Lock locks1 = new Lock();
                                    locks1.data = lockModel1;
                                    MilkTeaSocket.Instance.SendMsg(JsonConvert.SerializeObject(locks1) + "###");
                                }
                                else if (lockInit == 40)
                                {
                                    break;
                                }
                            }
                            Thread.Sleep(1000);
                            RobotModelLeft.Instance.RobotCNCWC_UP();
                            Thread.Sleep(100);
                            IOSerialPort.Instance.SerialSend(DigitalMsg.Instance.MilkTeaMachineLight_end);
                            Thread.Sleep(100);
                            if (SignageInit == "3")
                            {
                                while (!coffeeMsg.Instance.isMaking) { Thread.Sleep(10); }
                                Thread.Sleep(100);
                                IOSerialPort.Instance.SerialSend(DigitalMsg.Instance.CoffeeLight_start);
                                Thread.Sleep(100);
                                RobotModelLeft.Instance.RobotQKFJ_UP();
                                Thread.Sleep(100);
                                RobotModelLeft.Instance.RobotCNCWC_Down();
                                Thread.Sleep(100);
                                #region 咖博士
                                coffeeMsg.Instance.AllBol = false;
                                Thread.Sleep(500);
                                MakeCoffeeNow(code, CupInit, IceInit);
                                Thread.Sleep(500);
                                coffeeMsg.Instance.AllBol = true;
                                Thread.Sleep(100);
                                //IOSerialPort.Instance.SerialSend(DigitalMsg.Instance.LRobot_KFJ_Down);
                                //RobotModelLeft.Instance.QK();
                                Thread.Sleep(1000);
                                while (coffeeMsg.Instance.isMaking && (coffeeMsg.Instance.isBreakDown && coffeeMsg.Instance.isWarn)) { Thread.Sleep(10); }
                                Thread.Sleep(1000);
                                while ((!coffeeMsg.Instance.isMaking && !coffeeMsg.Instance.IsJBol) && (coffeeMsg.Instance.isBreakDown && coffeeMsg.Instance.isWarn)) { Thread.Sleep(10); }
                                #endregion
                                Thread.Sleep(100);
                                RobotModelLeft.Instance.RobotCKFWC_UP();
                                Thread.Sleep(100);
                                RobotModelLeft.Instance.RobotQKFJ_Down();
                                Thread.Sleep(100);
                                IOSerialPort.Instance.SerialSend(DigitalMsg.Instance.CoffeeLight_end);
                                Thread.Sleep(100);
                            }
                        }
                        Thread.Sleep(100);
                        RobotModelLeft.Instance.RobotJBCG_Down();
                        Thread.Sleep(100);

                        //if (cupSealModel == 1)
                        //{
                        if (order.sealingFilm == "1")
                        {
                            RobotModelLeft.Instance.RobotQYM_UP();
                            Thread.Sleep(100);
                            while (true)
                            {
                                Console.WriteLine("daojiebeidian1 " + DateTime.Now.ToString());
                                bool RobotBol = false;
                                Thread.Sleep(200);
                                RobotBol = RobotModelLeft.Instance.LRobotDYMJ_Sel();
                                Thread.Sleep(200);
                                if (RobotBol)
                                {
                                    RobotModelLeft.Instance.RobotQYM_Down();
                                    Thread.Sleep(100);
                                    RobotModelLeft.Instance.RobotCBWC_Down();
                                    Thread.Sleep(100);
                                    RobotModelLeft.Instance.RobotCNCWC_Down();
                                    Thread.Sleep(100);
                                    break;
                                }
                            }
                            RobotModelLeft.Instance.RobotQTZ_UP();
                            Thread.Sleep(100);
                            IOSerialPort.Instance.SerialSend(DigitalMsg.Instance.LabelingMachineLight_start);
                            Thread.Sleep(100);
                            while (true)
                            {
                                bool RobotBol = false;
                                Thread.Sleep(200);
                                RobotBol = RobotModelLeft.Instance.LRobotDTZ_Sel();
                                Thread.Sleep(200);
                                if (RobotBol)
                                {
                                    RobotModelLeft.Instance.RobotQTZ_Down();
                                    Thread.Sleep(100);
                                    break;
                                }
                            }

                            LabelMsg.Instance.USBShow(order.label);
                            Thread.Sleep(2000);
                            IOSerialPort.Instance.SerialSend(DigitalMsg.Instance.LabelingMachine_start);
                            Thread.Sleep(2500);
                            IOSerialPort.Instance.SerialSend(DigitalMsg.Instance.LabelingMachine_end);
                            Thread.Sleep(1000);
                            RobotModelLeft.Instance.RobotTZWC_UP();
                            Thread.Sleep(100);
                            IOSerialPort.Instance.SerialSend(DigitalMsg.Instance.LabelingMachineLight_end);
                            Thread.Sleep(100);
                        }
                        else
                        {
                            RobotModelLeft.Instance.RobotQTZ_UP();
                            Thread.Sleep(100);
                            IOSerialPort.Instance.SerialSend(DigitalMsg.Instance.LabelingMachineLight_start);
                            Thread.Sleep(100);
                            while (true)
                            {
                                bool RobotBol = false;
                                Thread.Sleep(200);
                                RobotBol = RobotModelLeft.Instance.LRobotDTZ_Sel();
                                Thread.Sleep(200);
                                if (RobotBol)
                                {
                                    RobotModelLeft.Instance.RobotQTZ_Down();
                                    Thread.Sleep(100);
                                    RobotModelLeft.Instance.RobotCBWC_Down();
                                    Thread.Sleep(100);
                                    RobotModelLeft.Instance.RobotCNCWC_Down();
                                    Thread.Sleep(100);
                                    break;
                                }
                            }

                            LabelMsg.Instance.USBShow(order.label);
                            Thread.Sleep(2000);
                            IOSerialPort.Instance.SerialSend(DigitalMsg.Instance.LabelingMachine_start);
                            Thread.Sleep(2500);
                            IOSerialPort.Instance.SerialSend(DigitalMsg.Instance.LabelingMachine_end);
                            Thread.Sleep(1000);
                            RobotModelLeft.Instance.RobotTZWC_UP();
                            Thread.Sleep(100);
                            IOSerialPort.Instance.SerialSend(DigitalMsg.Instance.LabelingMachineLight_end);
                            Thread.Sleep(100);
                        }
                        Thread.Sleep(100);
                        RobotModelLeft.Instance.RobotCKFWC_Down();
                        Thread.Sleep(100);
                        RobotModelLeft.Instance.RobotTZWC_Down();
                        Thread.Sleep(100);
                        if (SignageInit == "1")
                            RobotModelLeft.Instance.RobotKFP_Down();
                        else if (SignageInit == "2")
                            RobotModelLeft.Instance.RobotNCP_Down();
                        else
                            RobotModelLeft.Instance.RobotHHP_Down();
                        Thread.Sleep(100);
                        if (IceInit != "12")
                            RobotModelLeft.Instance.RobotQJB_Down();
                        Thread.Sleep(100);
                        if (order.sealingFilm == "1")
                            RobotModelLeft.Instance.RobotQYM_Down();
                        else
                            RobotModelLeft.Instance.RobotWGWM_Down();
                        //}
                        //else
                        //{
                        //    YGMsg(CupInit);
                        //    RobotModelLeft.Instance.RobotQTZ_UP();
                        //    Thread.Sleep(100);
                        //    IOSerialPort.Instance.SerialSend(DigitalMsg.Instance.LabelingMachineLight_start);
                        //    Thread.Sleep(100);
                        //    while (true)
                        //    {
                        //        bool RobotBol = false;
                        //        Thread.Sleep(200);
                        //        RobotBol = RobotModelLeft.Instance.LRobotDTZ_Sel();
                        //        Thread.Sleep(200);
                        //        if (RobotBol)
                        //        {
                        //            break;
                        //        }
                        //    }
                        //    IOSerialPort.Instance.SerialSend(DigitalMsg.Instance.LabelingMachine_start);
                        //    LabelMsg.Instance.USBShow(order.label);
                        //    Thread.Sleep(5000);
                        //    IOSerialPort.Instance.SerialSend(DigitalMsg.Instance.LabelingMachine_end);
                        //    Thread.Sleep(1000);
                        //    RobotModelLeft.Instance.RobotTZWC_UP();
                        //    Thread.Sleep(100);
                        //    IOSerialPort.Instance.SerialSend(DigitalMsg.Instance.LabelingMachineLight_end);
                        //    Thread.Sleep(100);
                        //}
                        if (!WuLiaoCoffeeSel.Instance.OutMealCup_Sel_Bol1)
                        {
                            RobotModelLeft.Instance.RobotQCC1_UP();
                            CcInit = 1;
                        }
                        else if (!WuLiaoCoffeeSel.Instance.OutMealCup_Sel_Bol2)
                        {
                            RobotModelLeft.Instance.RobotQCC2_UP();
                            CcInit = 2;
                        }
                        else if (!WuLiaoCoffeeSel.Instance.OutMealCup_Sel_Bol3)
                        {
                            RobotModelLeft.Instance.RobotQCC3_UP();
                            CcInit = 3;
                        }
                        else if (!WuLiaoCoffeeSel.Instance.OutMealCup_Sel_Bol4)
                        {
                            RobotModelLeft.Instance.RobotQCC4_UP();
                            CcInit = 4;
                        }
                        Thread.Sleep(100);
                        while (true)
                        {
                            bool RobotBol = false;
                            Thread.Sleep(200);
                            RobotBol = RobotModelLeft.Instance.LRobotZSWC_Sel();
                            Thread.Sleep(200);
                            if (RobotBol)
                            {
                                if (CcInit == 1)
                                    RobotModelLeft.Instance.RobotQCC1_Down();
                                else if (CcInit == 2)
                                    RobotModelLeft.Instance.RobotQCC2_Down();
                                else if (CcInit == 3)
                                    RobotModelLeft.Instance.RobotQCC3_Down();
                                else
                                    RobotModelLeft.Instance.RobotQCC4_Down();
                                break;
                            }
                        }
                        updateOrderStatus editDevice2 = new updateOrderStatus();
                        editDevice2.productId = IPorPortInfo.Instance.ProductId;
                        editDevice2.deviceName = IPorPortInfo.Instance.DeviceName;
                        editDevice2.orderId = orderId;
                        editDevice2.childOrderId = order.childOrderId;
                        editDevice2.pickUpLocation = CcInit == 1 ? "A" : CcInit == 2 ? "B" : CcInit == 3 ? "C" : "D";
                        editDevice2.status = "2";
                        string lists2 = JsonConvert.SerializeObject(editDevice2);
                        var dd2 = HttpMsg.Instance.editDeviceOrderStatusMsg(lists2);
                        CCUpDateOrder cc = new CCUpDateOrder();
                        cc.status = editDevice2;
                        cc.CcInit = CcInit;
                        updateOrders.Add(cc);
                        //RobotModelLeft.Instance.QK();
                        MilkTeaSocket.Instance.AllBol = true;
                        break;
                    }
                    else
                    {
                        Thread.Sleep(200);
                        RobotModelLeft.Instance.RobotWBTZ_UP();
                        Thread.Sleep(200);
                        RobotModelLeft.Instance.RobotQBJC_Down();
                        Thread.Sleep(200);
                        RobotModelLeft.Instance.RobotQJB16_Down();
                        Thread.Sleep(200);
                        RobotModelLeft.Instance.RobotQJB22_Down();
                        Thread.Sleep(200);
                        QBMsg(CupInit);
                        Thread.Sleep(200);
                    }
                    Thread.Sleep(10);
                }

            }
            catch (Exception)
            {

                throw;
            }
        }
        public static void YGMsg(string CupInit)
        {
            try
            {
                Thread.Sleep(200);
                RobotModelLeft.Instance.RobotQJG_UP();
                Thread.Sleep(200);
                while (true)
                {
                    bool RobotBol = false;
                    Thread.Sleep(200);
                    RobotBol = RobotModelLeft.Instance.LRobotDJG_Sel();
                    Thread.Sleep(200);
                    if (RobotBol)
                    {
                        break;
                    }
                }
                IOSerialPort.Instance.SerialSend(DigitalMsg.Instance.Drop_Lid_start);
                Thread.Sleep(100);
                while (WuLiaoCoffeeSel.Instance.LGQFK1_Sel_Bol) { Thread.Sleep(10); }
                while (!WuLiaoCoffeeSel.Instance.LGQFK1_Sel_Bol) { Thread.Sleep(10); }
                Thread.Sleep(100);
                IOSerialPort.Instance.SerialSend(DigitalMsg.Instance.Drop_Lid_end);
                Thread.Sleep(500);
                RobotModelLeft.Instance.RobotJGWC_UP();
                Thread.Sleep(200);
                while (true)
                {
                    bool RobotBol = false;
                    Thread.Sleep(200);
                    RobotBol = RobotModelLeft.Instance.LRobotDYG_Sel();
                    Thread.Sleep(200);
                    if (RobotBol)
                    {
                        break;
                    }
                }
                int YGInit = 0;
                if (CupInit == "01" || CupInit == "10")
                {
                    Thread.Sleep(200);
                    IOSerialPort.Instance.SerialSend(DigitalMsg.Instance.Cap_Cover_UP_start);
                    Thread.Sleep(100);
                    while (!WuLiaoCoffeeSel.Instance.CapPressingUP_Sel_Bol)
                    {
                        Thread.Sleep(100);
                        YGInit++;
                        if (YGInit >= 30)
                        {
                            break;
                        }
                    }
                    Thread.Sleep(100);
                    IOSerialPort.Instance.SerialSend(DigitalMsg.Instance.Cap_Cover_UP_end);
                }
                else
                {
                    Thread.Sleep(200);
                    IOSerialPort.Instance.SerialSend(DigitalMsg.Instance.Cap_Cover_Middle_start);
                    Thread.Sleep(100);
                    while (!WuLiaoCoffeeSel.Instance.CapPressingMin_Sel_Bol)
                    {
                        Thread.Sleep(100);
                        YGInit++;
                        if (YGInit >= 30)
                        {
                            break;
                        }
                    }
                    Thread.Sleep(100);
                    IOSerialPort.Instance.SerialSend(DigitalMsg.Instance.Cap_Cover_Middle_end);
                }
                Thread.Sleep(1000);
                IOSerialPort.Instance.SerialSend(DigitalMsg.Instance.Cap_Cover_Down_start);
                Thread.Sleep(100);
                while (!WuLiaoCoffeeSel.Instance.CapPressingDown_Sel_Bol)
                {
                    Thread.Sleep(100);
                }
                Thread.Sleep(100);
                IOSerialPort.Instance.SerialSend(DigitalMsg.Instance.Cap_Cover_Down_end);
                Thread.Sleep(100);
            }
            catch (Exception)
            {
            }
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="IceInit">10 正常冰</param>
        /// <param name="type"> 1咖啡  别的奶茶</param>
        public static void JIceMsg(string IceInit, string type, string CupInit)
        {
            try
            {
                Thread.Sleep(200);
                RobotModelLeft.Instance.RobotQJB_UP();
                Thread.Sleep(200);
                IOSerialPort.Instance.SerialSend(DigitalMsg.Instance.IceMakerLight_start);
                while (true)
                {
                    bool RobotBol = false;
                    Thread.Sleep(200);
                    RobotBol = RobotModelLeft.Instance.LRobotDZBJ_Sel();
                    Thread.Sleep(200);
                    if (RobotBol)
                    {
                        RobotModelLeft.Instance.RobotQJB_Down();
                        Thread.Sleep(200);
                        break;
                    }
                }
                IceMakingMsg.Instance.AllBol = false;
                Thread.Sleep(1000);
                IceMakingSerialPort.Instance.SerialSend(IceMakingModel.Instance.IceMakingStart);
                if (type == "1")
                    Thread.Sleep(Convert.ToInt32(IPorPortInfo.Instance.IceCoffee * 1000 * (IceInit == "10" && CupInit == "10" ? 1 : IceInit == "10" && CupInit == "00" ? 0.9 : IceInit == "11" && CupInit == "10" ? 0.9 : 0.8)));
                else
                    Thread.Sleep(Convert.ToInt32(IPorPortInfo.Instance.IceMilk * 1000 * (IceInit == "10" && CupInit == "01" ? 1 : IceInit == "10" && CupInit == "02" ? 1.2 : IceInit == "10" && CupInit == "10" ? 0.75 : IceInit == "11" && CupInit == "01" ? 0.75 : IceInit == "11" && CupInit == "02" ? 1 : 0.5)));
                IceMakingSerialPort.Instance.SerialSend(IceMakingModel.Instance.IceMakingEnd);
                Console.WriteLine(IceMakingModel.Instance.IceMaking2 + "  " + DateTime.Now.ToString());
                Thread.Sleep(1000);
                if (type == "1")
                {
                    for (int i = 0; i < 2; i++)
                    {
                        if (!WuLiaoCoffeeSel.Instance.CoffeeWeight_Sel_Bol)
                        {
                            IceMakingSerialPort.Instance.SerialSend(IceMakingModel.Instance.IceMakingStart);
                            Thread.Sleep(500);
                            IceMakingSerialPort.Instance.SerialSend(IceMakingModel.Instance.IceMakingEnd);
                        }
                        else
                        {
                            break;
                        }
                        Thread.Sleep(1000);
                    }
                }
                else
                {
                    for (int i = 0; i < 2; i++)
                    {
                        if (!WuLiaoCoffeeSel.Instance.MilkWeight_Sel_Bol)
                        {
                            IceMakingSerialPort.Instance.SerialSend(IceMakingModel.Instance.IceMakingStart);
                            Thread.Sleep(500);
                            IceMakingSerialPort.Instance.SerialSend(IceMakingModel.Instance.IceMakingEnd);
                        }
                        else
                        {
                            break;
                        }
                        Thread.Sleep(1000);
                    }
                }
                //while (!IceMakingMsg.Instance.ZBJWCBol) { Thread.Sleep(10); }
                Thread.Sleep(1000);
                IceMakingMsg.Instance.AllBol = true;
                IceMakingMsg.Instance.ZBJWCBol = false;
                Thread.Sleep(1000);
                RobotModelLeft.Instance.RobotCBWC_UP();
                Thread.Sleep(200);
                IOSerialPort.Instance.SerialSend(DigitalMsg.Instance.IceMakerLight_end);
            }
            catch (Exception)
            {
                return;
            }
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="coffeename"></param>
        /// <param name="CupInit"></param>
        public static void MakeCoffeeNow(string coffeename, string CupInit, string IceInit)
        {
            try
            {
                Console.WriteLine("咖啡品 " + coffeename + "  " + CupInit + "  " + IceInit);
                switch (coffeename)
                {
                    case "010":
                    case "011":
                    case "012":
                    case "013":
                        CoffeeSerialPort.Instance.SerialSend(CoffeeMake.espresso);
                        break;
                    case "017":
                        if (CupInit == "10")
                            CoffeeSerialPort.Instance.SerialSend(CoffeeMake.latteBig2);
                        else
                            CoffeeSerialPort.Instance.SerialSend(CoffeeMake.latteMin2);
                        break;
                    case "001":
                        if (CupInit == "01" || CupInit == "10")
                        {
                            if (IceInit == "12")
                                CoffeeSerialPort.Instance.SerialSend(CoffeeMake.AmericanoBig);
                            else
                                CoffeeSerialPort.Instance.SerialSend(CoffeeMake.IceAmericanoBig);
                        }
                        else
                        {
                            if (IceInit == "12")
                                CoffeeSerialPort.Instance.SerialSend(CoffeeMake.AmericanoMin);
                            else
                                CoffeeSerialPort.Instance.SerialSend(CoffeeMake.IceAmericanoMin);
                        }
                        break;
                    case "002":
                        if (CupInit == "01" || CupInit == "10")
                        {
                            if (IceInit == "12")
                                CoffeeSerialPort.Instance.SerialSend(CoffeeMake.MilklatteBig3);
                            else
                                CoffeeSerialPort.Instance.SerialSend(CoffeeMake.MilkIcelatteBig3);
                        }
                        else
                        {
                            if (IceInit == "12")
                                CoffeeSerialPort.Instance.SerialSend(CoffeeMake.MilklatteMin3);
                            else
                                CoffeeSerialPort.Instance.SerialSend(CoffeeMake.MilkIcelatteMin3);
                        }
                        break;
                    case "003":
                        if (CupInit == "01" || CupInit == "10")
                        {
                            if (IceInit == "12")
                                CoffeeSerialPort.Instance.SerialSend(CoffeeMake.MilklatteBig2);
                            else
                                CoffeeSerialPort.Instance.SerialSend(CoffeeMake.MilkIcelatteBig2);
                        }
                        else
                        {
                            if (IceInit == "12")
                                CoffeeSerialPort.Instance.SerialSend(CoffeeMake.MilklatteMin2);
                            else
                                CoffeeSerialPort.Instance.SerialSend(CoffeeMake.MilkIcelatteMin2);
                        }
                        break;
                    case "018":
                        if (CupInit == "01" || CupInit == "10")
                            CoffeeSerialPort.Instance.SerialSend(CoffeeMake.latteBig);
                        else
                            CoffeeSerialPort.Instance.SerialSend(CoffeeMake.latteMin);
                        break;
                    default:
                        CoffeeSerialPort.Instance.SerialSend(CoffeeMake.espresso);
                        break;
                }
            }
            catch (Exception)
            {
                return;
            }
        }
        /// <summary>
        /// 取杯
        /// </summary>
        /// <param name="cupCode"></param>
        public static void QBMsg(string CupInit)
        {
            try
            {
                Thread.Sleep(200);
                if (CupInit == "00")
                    RobotModelLeft.Instance.RobotQJB12_UP();
                else if (CupInit == "01" || CupInit == "10")
                    RobotModelLeft.Instance.RobotQJB16_UP();
                else
                    RobotModelLeft.Instance.RobotQJB22_UP();
                Thread.Sleep(100);
                RobotModelLeft.Instance.RobotQJBL_UP();
                while (true)
                {
                    Console.WriteLine("daojiebeidian1 " + DateTime.Now.ToString());
                    bool RobotBol = false;
                    Thread.Sleep(200);
                    RobotBol = RobotModelLeft.Instance.LRobotDLBQ_Sel();
                    Thread.Sleep(200);
                    if (RobotBol)
                    {
                        Thread.Sleep(100);
                        RobotModelLeft.Instance.RobotQJBL_Down();
                        Thread.Sleep(100);
                        RobotModelLeft.Instance.RobotWBTZ_Down();
                        Thread.Sleep(100);
                        if (CupInit == "00")
                            RobotModelLeft.Instance.RobotQJB12_Down();
                        else if (CupInit == "01" || CupInit == "10")
                            RobotModelLeft.Instance.RobotQJB16_Down();
                        else
                            RobotModelLeft.Instance.RobotQJB22_Down();
                        Thread.Sleep(100);
                        break;
                    }
                }
                Thread.Sleep(200);
                if (CupInit == "00")
                    IOSerialPort.Instance.SerialSend(DigitalMsg.Instance.Drop_Lid_start);
                else if (CupInit == "01" || CupInit == "10")
                    IOSerialPort.Instance.SerialSend(DigitalMsg.Instance.Drop_Cup_start);
                else
                    IOSerialPort.Instance.SerialSend(DigitalMsg.Instance.Drop_Cup2_start);
                Thread.Sleep(100);
                if (CupInit == "00")
                {
                    while (WuLiaoCoffeeSel.Instance.LGQFK1_Sel_Bol) { Thread.Sleep(10); }
                    while (!WuLiaoCoffeeSel.Instance.LGQFK1_Sel_Bol) { Thread.Sleep(10); }
                }
                else if (CupInit == "01" || CupInit == "10")
                {
                    while (WuLiaoCoffeeSel.Instance.LBQFK1_Sel_Bol) { Thread.Sleep(10); }
                    while (!WuLiaoCoffeeSel.Instance.LBQFK1_Sel_Bol) { Thread.Sleep(10); }
                }
                else
                {
                    while (WuLiaoCoffeeSel.Instance.LBQFK2_Sel_Bol) { Thread.Sleep(10); }
                    while (!WuLiaoCoffeeSel.Instance.LBQFK2_Sel_Bol) { Thread.Sleep(10); }
                }
                Thread.Sleep(150);
                if (CupInit == "00")
                    IOSerialPort.Instance.SerialSend(DigitalMsg.Instance.Drop_Lid_end);
                else if (CupInit == "01" || CupInit == "10")
                    IOSerialPort.Instance.SerialSend(DigitalMsg.Instance.Drop_Cup_end);
                else
                    IOSerialPort.Instance.SerialSend(DigitalMsg.Instance.Drop_Cup2_end);
                Thread.Sleep(500);
                RobotModelLeft.Instance.RobotQBJC_UP();
                Thread.Sleep(500);
                //IOMsg.Instance.RobotBol = false;
                while (true)
                {
                    bool RobotBol = false;
                    Thread.Sleep(100);
                    RobotBol = RobotModelLeft.Instance.LRobotQJBJC_Sel();
                    Thread.Sleep(100);
                    if (RobotBol)
                    {
                        Thread.Sleep(100);
                        RobotModelLeft.Instance.RobotQBJC_Down();
                        Thread.Sleep(100);
                        break;
                    }
                }
                // IOMsg.Instance.AllBol = true;
            }
            catch (Exception)
            {
                return;
            }
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                IceMakingMsg.Instance.AllBol = false;
                Thread.Sleep(1000);
                IceMakingSerialPort.Instance.SerialSend(IceMakingModel.Instance.IceMakingStart);
                Thread.Sleep(2000);
                IceMakingSerialPort.Instance.SerialSend(IceMakingModel.Instance.IceMakingEnd);
                Thread.Sleep(1000);
                IceMakingMsg.Instance.AllBol = true;
                IceMakingMsg.Instance.ZBJWCBol = false;
                //IceMakingMsg.Instance.AllBol = false;
                //Thread.Sleep(1000);
                //IceMakingSerialPort.Instance.SerialSend(IceMakingModel.Instance.IceMaking2);
                //Console.WriteLine(IceMakingModel.Instance.IceMaking2 + "  " + DateTime.Now.ToString());
                //Thread.Sleep(1000);
                //if (!IceMakingMsg.Instance.ZBJWCBol) { Thread.Sleep(10); }
                //Thread.Sleep(1000);
                //IceMakingMsg.Instance.AllBol = true;
                //IceMakingMsg.Instance.ZBJWCBol = false;
                Console.WriteLine("完成出冰");
            }
            catch (Exception)
            {

                throw;
            }
        }

        private void Button1_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                string labels = "Z100|黄皮花魁轻咖|3分糖|少冰|中杯|2025-07-30 13:46:22|外卖|千里千寻总店|1/5|4001001111|2小时饮用更好喝哦";
                LabelMsg.Instance.USBShow(labels);
            }
            catch (Exception)
            {

            }
        }
    }
}
